#include <gtest/gtest.h>

#include <Request/Downloader.h>
#include <QCoreApplication>

using namespace TC;
using namespace TC::Request;
//using namespace std;

TEST(Request_Downloader, download)
{
	Downloader downloader;
	QObject::connect(&downloader, &Downloader::error, [&]()
	{
		qWarning() << "Error : " << downloader.errorString();
	});
	downloader.download(QUrl("http://www.163.com"));
	while (Downloader::Status::Communicating == downloader.status())
		QCoreApplication::processEvents();
	ASSERT_EQ(Downloader::Status::Ok, downloader.status());

	if(!downloader.text().contains("html"))
	{
		qWarning() << "data downloaded : " << downloader.text() << endl;
	}
	ASSERT_TRUE(downloader.text().contains("html"));
}